package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.SelectKey;
import org.example.mapper.UserMapper;
import org.example.mode.RegisterUser;
import org.example.service.UerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Slf4j
public class AuthController {
    @Autowired
    UerService uerService;

    @PostMapping("/register")
    public  String register(@RequestBody RegisterUser user) {
        return uerService.registerUser(user);


    }
    @PostMapping("/login")
    public String login(@RequestBody RegisterUser user) {

        return uerService.login(user);
    }
    @DeleteMapping("/delete/{username}")
    public String deleteUser(@PathVariable String username) {
        return uerService.deleteUser(username);
    }
    @PutMapping("/update")
    public  String updateUser(@RequestBody RegisterUser user) {
        return  uerService.updateUser(user);
    }
}

